package com.lorenzogao.latte_core.net

import okhttp3.MultipartBody
import okhttp3.RequestBody
import okhttp3.Response
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.*

/**
 *  create by LorenzoGao
 *  email: 2508719070@qq.com
 *  TIME: 2020-01-08 11:29
 *  description:
 */

interface RestService {


    @GET
    fun get(@Url url: String, @QueryMap params: Map<String, String>): Call<String>


    @FormUrlEncoded
    @POST
    fun post(@Url url: String, @FieldMap params: Map<String, String>): Call<String>


    @POST
    fun postRaw(@Url url: String, @Body body:RequestBody): Call<String>

    @FormUrlEncoded
    @PUT
    fun put(@Url url: String, @FieldMap params: Map<String, String>): Call<String>


    @PUT
    fun putRaw(@Url url: String, @Body body:RequestBody): Call<String>


    @DELETE
    fun delete(@Url url: String, @QueryMap params: Map<String, String>): Call<String>


    // 防止内存溢出
    @Streaming  //边下载 边文件写入
    @GET
    fun download(@Url url: String, @QueryMap params: Map<String, String>): Call<ResponseBody>

    @Multipart
    @POST
    fun upload(@Url url: String, @Part file: MultipartBody.Part): Call<String>

}